﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using InkFx.WinControl.Core;
using InkFx.WinControl.Design;
using InkFx.WinControl.Utils;

namespace InkFx.WinControl.Theme
{
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage : ICloneable, IDisposable
    {
        private byte[] m_FileBytes = null;
        private string m_Base64OrFile = string.Empty;
        private byte m_IsBase64 = 0;

        /// <summary>
        /// 
        /// </summary>
        [Browsable(true), EditorBrowsable(EditorBrowsableState.Always), DesignerSerializationVisibility(DesignerSerializationVisibility.Visible), NotifyParentProperty(true)]
        public string Base64OrFile
        {
            get
            {
                string base64 = InitImageBase64();
                return base64;
            }
            set
            {
                Reset();
                m_Base64OrFile = value;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        [XmlIgnore, Browsable(false), EditorBrowsable(EditorBrowsableState.Never), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Localizable(false)]
        public byte[] FileBytes
        {
            get
            {
                byte[] bytes = InitFileBytes();
                return bytes;
            }
            set
            {
                Reset();
                m_FileBytes = value;
                //m_Base64OrFile = (m_FileBytes != null && m_FileBytes.Length >= 1) ? Convert.ToBase64String(m_FileBytes) : string.Empty;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public Image InitImage()
        {
            if (m_Image != null && !GUIHelper.ImageIsDisposed(m_Image) && m_Image.Width >= 1) return m_Image;
            //try { if (m_Image != null && !GUIHelper.ImageIsDisposed(m_Image) && m_Image.Width >= 1) return m_Image; } catch (Exception ex) { Tools.LogWarn(ex); }

            try
            {
                if (m_FileBytes != null && m_FileBytes.Length >= 1)
                {
                    m_Image = ImageHelper.GetImageFromBytes(m_FileBytes);
                }
                else if (Tools.IsBase64(m_Base64OrFile))
                {
                    m_Image = ImageHelper.GetImageFromBase64(m_Base64OrFile);
                }
            }
            catch (Exception ex) { Tools.LogWarn(ex); m_Image = null; }

            return m_Image;
        }
        /// <summary>
        /// 
        /// </summary>
        public Image Image0 { get { return GetSplitYImage(0); } }

        private byte[] InitFileBytes()
        {
            if (m_FileBytes != null && m_FileBytes.Length >= 1) return m_FileBytes;

            try
            {
                string base64OrFile = m_Base64OrFile;
                if (!Tools.IsBase64(m_Base64OrFile)) return null;

                ////Base64OrFile 属性赋值时 判断了 File.Exists(*) 并进行了转换, 这里不用再判断 File.Exists(*)
                //if (File.Exists(base64OrFile))
                //    m_FileBytes = FileHelper.ReadFileBytes(base64OrFile);
                //else
                m_FileBytes = Convert.FromBase64String(base64OrFile);
            }
            catch (Exception ex) { Tools.LogWarn(ex); m_FileBytes = null; }

            return m_FileBytes;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string InitImageBase64()
        {
            if (m_IsBase64 == 0 && !Tools.IsNullOrWhiteSpace(m_Base64OrFile))
            {
                if (FileHelper.ExistFile(m_Base64OrFile))
                {
                    m_FileBytes = FileHelper.ReadFileBytes(m_Base64OrFile);
                    m_Base64OrFile = Convert.ToBase64String(m_FileBytes);
                    m_IsBase64 = 1;
                    return m_Base64OrFile;
                }
                else
                {
                    try
                    {
                        var bytes = Convert.FromBase64String(m_Base64OrFile);
                        m_FileBytes = bytes;
                        m_IsBase64 = 1;
                        return m_Base64OrFile;
                    }
                    catch (Exception ex) { /*Tools.LogWarn2(ex, "Base64: " + m_Base64OrFile);*/ }
                }
            }

            if (!Tools.IsNullOrWhiteSpace(m_Base64OrFile)) return m_Base64OrFile;

            try
            {
                byte[] bytes = m_FileBytes;
                if (bytes == null || bytes.Length <= 0) return string.Empty;

                m_Base64OrFile = Convert.ToBase64String(bytes);
                m_IsBase64 = 1;
            }
            catch (Exception ex) { Tools.LogWarn(ex); m_Base64OrFile = string.Empty; m_IsBase64 = 0; }

            return m_Base64OrFile;
        }


        //private static string GetJsonAttrName(MemberInfo member)
        //{
        //    Attribute[] attrs = Attribute.GetCustomAttributes(member, true);
        //    if (attrs.Length <= 0) return string.Empty;

        //    foreach (Attribute attr in attrs)
        //    {
        //        string typeName = attr.GetType().Name;
        //        if (string.Equals(typeName, "JsonIgnoreAttribute", StringComparison.InvariantCultureIgnoreCase)) { return null; }
        //        if (string.Equals(typeName, "JsonPropertyAttribute", StringComparison.InvariantCultureIgnoreCase))
        //        {
        //            string jsonName = (attr.GetType().GetProperty("PropertyName").GetValue(attr, null) ?? string.Empty).ToString().Trim();
        //            return jsonName;
        //        }
        //    }

        //    return string.Empty;
        //}


        private const int MAX_SPLIT_COUNT = 32;
        private Image m_Image = null;
        private Image[] m_SplitArray = new Image[MAX_SPLIT_COUNT];

        /// <summary>
        /// 
        /// </summary>
        public virtual int SplitCount
        {
            get { return 1; }
            //set { throw new NotImplementedException("SkinImage.set_SplitCount(int)"); }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="index">Type: int</param>
        /// <returns></returns>
        public Image GetSplitYImage(int index)
        {
            if (index > MAX_SPLIT_COUNT - 1) return null;
            Image img = m_SplitArray == null ? null : m_SplitArray[index];
            //try { if (img != null /*&& !GUIHelper.ImageIsDisposed(img)*/ && img.Width >= 1) return img; } catch (Exception ex) { Tools.LogWarn(ex); }
            if (img != null && !GUIHelper.ImageIsDisposed(img) && img.Width >= 1) return img;

            Image image = InitImage();
            int count = SplitCount;
            img = GUIHelper.SplitYImage(image, count, index);

            if (m_SplitArray == null) m_SplitArray = new Image[MAX_SPLIT_COUNT];
            m_SplitArray[index] = img;
            return img;
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual void Reset()
        {
            m_IsBase64 = 0;
            m_FileBytes = null;
            m_Base64OrFile = string.Empty;

            try { if (m_Image != null) { m_Image.Dispose(); } } catch { m_Image = null; }

            if (m_SplitArray != null)
            {
                for (int i = 0, c = m_SplitArray.Length; i < c; i++)
                {
                    Image img = m_SplitArray[i];
                    try { if (img != null) { img.Dispose(); } } catch { m_SplitArray[i] = null; }
                }
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public int Width
        {
            get
            {
                Image image = this.InitImage();
                return image == null ? 0 : image.Width;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public int Height
        {
            get
            {
                Image image = this.InitImage();
                return image == null ? 0 : image.Height;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public Size Size
        {
            get { return new Size(Width, Height); }
        }
        /// <summary>
        /// 
        /// </summary>
        public int SingleWidth
        {
            get { return Width; }
        }
        /// <summary>
        /// 
        /// </summary>
        public int SingleHeight
        {
            get { return Height / SplitCount; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Size SingleSize
        {
            get { return new Size(SingleWidth, SingleHeight); }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool IsEmpty
        {
            get
            {
                Image image = this.InitImage();
                return image == null || image.Width <= 0 || image.Height <= 0;
            }
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static string GetImageBase64(Image img)
        {
            using (MemoryStream ms = new MemoryStream())
            {
                img.Save(ms, ImageFormat.Png);
                return Convert.ToBase64String(ms.ToArray());
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="skinImg">Type: SkinImage</param>
        /// <returns></returns>
        [Obsolete("请明确调用 SkinImage 对应的Image, 而避免使用隐式转换", false)]
        public static implicit operator Image(SkinImage skinImg)
        {
            if (skinImg == null) return null;
            return skinImg.InitImage();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        [Obsolete("请明确调用 Image 对应的SkinImage, 而避免使用隐式转换", false)]
        public static implicit operator SkinImage(Image img)
        {
            if (img == null) return null;
            SkinImage skinImg = new SkinImage();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="v">Type: int</param>
        /// <param name="rect">Type: RectangleF</param>
        public void DrawImage(Graphics g, int v, RectangleF rect)
        {
            if (v >= SplitCount) return;
            if (this.IsEmpty) return;
            if (rect.Width <= 0 || rect.Height <= 0) return;


            //g.InterpolationMode = InterpolationMode.HighQualityBilinear;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            Image img = this.GetSplitYImage(v);
            GUIHelper.DrawImageCenter2(g, img, rect);
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinImage() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="img">Type: Image</param>
        public SkinImage(Image img)
        {
            this.Base64OrFile = GetImageBase64(img);
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="imgBase64">Type: string</param>
        public SkinImage(string imgBase64)
        {
            this.Base64OrFile = imgBase64;
        }

        /// <summary>
        /// 创建作为当前实例副本的新对象。
        /// </summary>
        /// <returns>作为此实例副本的新对象。</returns>
        public virtual object Clone()
        {
            Type type = this.GetType();
            SkinImage clone = (SkinImage)Activator.CreateInstance(type);

            clone.m_FileBytes = this.m_FileBytes;
            clone.m_Base64OrFile = this.m_Base64OrFile;
            clone.m_IsBase64 = this.m_IsBase64;

            clone.m_Image = GUIHelper.ImageIsDisposed(this.m_Image) ? null : this.m_Image.Clone() as Image;
            for (int i = 0, len = this.m_SplitArray.Length; i < len; i++)
            {
                Image image = this.m_SplitArray[i];
                clone.m_SplitArray[i] = GUIHelper.ImageIsDisposed(image) ? null : image.Clone() as Image;
            }

            return clone;
        }
        /// <summary>
        /// 返回表示当前 System.Object 的 System.String。
        /// </summary>
        /// <returns>System.String，表示当前的 System.Object。</returns>
        public override string ToString()
        {
            return this.GetType().Name;
        }
        /// <summary>
        /// 执行与释放或重置非托管资源相关的应用程序定义的任务。
        /// </summary>
        public virtual void Dispose()
        {
            Reset();
            m_Image = null;
            m_SplitArray = null;
            m_FileBytes = null;
            m_Base64OrFile = string.Empty;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V2 : SkinImage
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 2; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image1 { get { return GetSplitYImage(1); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V2(Image img)
        {
            if (img == null) return null;
            SkinImage_V2 skinImg = new SkinImage_V2();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V3 : SkinImage_V2
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 3; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image2 { get { return GetSplitYImage(2); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V3(Image img)
        {
            if (img == null) return null;
            SkinImage_V3 skinImg = new SkinImage_V3();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V4 : SkinImage_V3
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 4; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image3 { get { return GetSplitYImage(3); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V4(Image img)
        {
            if (img == null) return null;
            SkinImage_V4 skinImg = new SkinImage_V4();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V5 : SkinImage_V4
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 5; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image4 { get { return GetSplitYImage(4); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V5(Image img)
        {
            if (img == null) return null;
            SkinImage_V5 skinImg = new SkinImage_V5();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V6 : SkinImage_V5
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 6; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image5 { get { return GetSplitYImage(5); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V6(Image img)
        {
            if (img == null) return null;
            SkinImage_V6 skinImg = new SkinImage_V6();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V8 : SkinImage_V6
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 8; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image6 { get { return GetSplitYImage(6); } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image7 { get { return GetSplitYImage(7); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V8(Image img)
        {
            if (img == null) return null;
            SkinImage_V8 skinImg = new SkinImage_V8();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V9 : SkinImage_V8
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 9; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image8 { get { return GetSplitYImage(8); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V9(Image img)
        {
            if (img == null) return null;
            SkinImage_V9 skinImg = new SkinImage_V9();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V10 : SkinImage_V9
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 10; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image9 { get { return GetSplitYImage(9); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V10(Image img)
        {
            if (img == null) return null;
            SkinImage_V10 skinImg = new SkinImage_V10();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V12 : SkinImage_V10
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 12; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image10 { get { return GetSplitYImage(10); } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image11 { get { return GetSplitYImage(11); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V12(Image img)
        {
            if (img == null) return null;
            SkinImage_V12 skinImg = new SkinImage_V12();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinImage_V16 : SkinImage_V12
    {
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount { get { return 16; } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image12 { get { return GetSplitYImage(12); } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image13 { get { return GetSplitYImage(13); } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image14 { get { return GetSplitYImage(14); } }
        /// <summary>
        /// 
        /// </summary>
        public Image Image15 { get { return GetSplitYImage(15); } }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="img">Type: Image</param>
        /// <returns></returns>
        public static implicit operator SkinImage_V16(Image img)
        {
            if (img == null) return null;
            SkinImage_V16 skinImg = new SkinImage_V16();
            skinImg.Base64OrFile = GetImageBase64(img);
            return skinImg;
        }
    }



    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage : ICloneable, IDisposable
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage</param>
        /// <param name="top">Type: int</param>
        /// <param name="bottom">Type: int</param>
        /// <param name="left">Type: int</param>
        /// <param name="right">Type: int</param>
        /// <param name="fillStyle">Type: FillStyle</param>
        public SkinBorderImage(SkinImage skinImg, int top, int bottom, int left, int right, FillStyle fillStyle)
        {
            if (skinImg == null) throw new ArgumentNullException("skinImg");
            this.SkinImage = skinImg;
            this.FillStyle = fillStyle;
            this.BorderOffset = new BorderOffset(top, bottom, left, right);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="skinImg">Type: SkinImage</param>
        /// <param name="top">Type: int</param>
        /// <param name="bottom">Type: int</param>
        /// <param name="left">Type: int</param>
        /// <param name="right">Type: int</param>
        /// <param name="fillStyle">Type: FillStyle</param>
        /// <returns></returns>
        public static SkinBorderImage CreateBorderImage(SkinImage skinImg, int top, int bottom, int left, int right, FillStyle fillStyle)
        {
            if (skinImg.SplitCount == 1) return new SkinBorderImage(skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 2) return new SkinBorderImage_V2((SkinImage_V2)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 3) return new SkinBorderImage_V3((SkinImage_V3)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 4) return new SkinBorderImage_V4((SkinImage_V4)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 6) return new SkinBorderImage_V6((SkinImage_V6)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 8) return new SkinBorderImage_V8((SkinImage_V8)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 9) return new SkinBorderImage_V9((SkinImage_V9)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 12) return new SkinBorderImage_V12((SkinImage_V12)skinImg, top, bottom, left, right, fillStyle);
            if (skinImg.SplitCount == 16) return new SkinBorderImage_V16((SkinImage_V16)skinImg, top, bottom, left, right, fillStyle);

            throw new Exception(string.Format("不能通过 {0} (SplitCount={2}) 初始化 {1} 实例", skinImg.GetType(), typeof(SkinBorderImage), skinImg.SplitCount));
        }



        private FillStyle m_FillStyle = FillStyle.Fill;
        private SkinImage m_SkinImage;
        private BorderOffset m_BorderOffset;
        private Hash<int, Hash<Hash<int, Image>>> m_HashImage = null;

        /// <summary>
        /// 
        /// </summary>
        public FillStyle FillStyle
        {
            get { return m_FillStyle; }
            set
            {
                m_FillStyle = value;
                ClearCache();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public SkinImage SkinImage
        {
            get { return m_SkinImage; }
            set
            {
                m_SkinImage = value;
                ClearCache();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public BorderOffset BorderOffset
        {
            get { return m_BorderOffset; }
            set
            {
                m_BorderOffset = value;
                ClearCache();
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public virtual int SplitCount
        {
            get { return 1; }
        }


        /// <summary>
        /// 
        /// </summary>
        public int Width
        {
            get
            {
                if (m_SkinImage == null) return 0;
                Image image = m_SkinImage.InitImage();
                return image == null ? 0 : image.Width;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public int Height
        {
            get
            {
                if (m_SkinImage == null) return 0;
                Image image = m_SkinImage.InitImage();
                return image == null ? 0 : image.Height;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public Size Size
        {
            get { return new Size(Width, Height); }
        }
        /// <summary>
        /// 
        /// </summary>
        public int SingleWidth
        {
            get { return Width; }
        }
        /// <summary>
        /// 
        /// </summary>
        public int SingleHeight
        {
            get { return Height/SplitCount; }
        }
        /// <summary>
        /// 
        /// </summary>
        public Size SingleSize
        {
            get { return new Size(SingleWidth, SingleHeight); }
        }
        /// <summary>
        /// 
        /// </summary>
        public bool IsEmpty
        {
            get
            {
                var image = this.m_SkinImage;
                return image == null || image.IsEmpty;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public virtual SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage();
            return SkinImage;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public string InitImageBase64()
        {
            try
            {
                return SkinImage == null ? string.Empty : SkinImage.InitImageBase64();
            }
            catch (Exception ex) { Tools.LogWarn(ex); return string.Empty; }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="v">Type: int</param>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public Image GetImage(int v, int hashCode, int width, int height)
        {
            if (v >= SplitCount) return null;
            if (width <= 0 || height <= 0) return null;

            string hashKey = string.Format("{0}x{1}", width, height);
            if (m_HashImage == null) m_HashImage = new Hash<int, Hash<Hash<int, Image>>>();

            #region  试图获取缓存图片

            Hash<Hash<int, Image>> hashSize = m_HashImage[v];
            Hash<int, Image> hashCtrl = hashSize == null ? null : hashSize[hashKey];
            if (hashCtrl != null && hashCtrl.Count >= 1)
            {
                KeyValuePair<int, Image> pairCtrl = hashCtrl.GetKeyValueByIndex(0);
                Image cache = pairCtrl.Value;
                if (cache != null && !GUIHelper.ImageIsDisposed(cache) && cache.Width >= 1)
                {
                    if (pairCtrl.Key != hashCode) hashCtrl[hashCode] = cache;
                    return cache;
                }
            }

            #endregion


            ClearCache(hashCode, v);
            SkinImage skinImg = SkinImage;
            BorderOffset offset = BorderOffset;
            FillStyle style = FillStyle;
            if (skinImg == null || skinImg.Image0 == null) return null;

            Bitmap bitmap = new Bitmap(width, height);
            bitmap.MakeTransparent(Color.Transparent);
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                //g.InterpolationMode = InterpolationMode.HighQualityBilinear;
                //g.SmoothingMode = SmoothingMode.AntiAlias;
                Image img = skinImg.GetSplitYImage(v);
                GUIHelper.DrawBorderImageAndFill(g, img, 0, 0, width, height, offset.Top, offset.Bottom, offset.Left, offset.Right, style);
            }

            if (hashSize == null) { hashSize = new Hash<Hash<int, Image>>(); m_HashImage[v] = hashSize; }
            if (hashCtrl == null) { hashCtrl = new Hash<int, Image>(); hashSize[hashKey] = hashCtrl; }
            hashCtrl[hashCode] = bitmap;

            //Directory.CreateDirectory(@"E:\TempSkinImage\");
            //bitmap.Save(string.Format(@"E:\TempSkinImage\{0}.png", hashCode + "_" + hashKey), ImageFormat.Png);
            return bitmap;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage0(int hashCode, int width, int height)
        {
            return GetImage(0, hashCode, width, height);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="v">Type: int</param>
        /// <param name="rect">Type: RectangleF</param>
        public void DrawImage(Graphics g, int v, RectangleF rect)
        {
            if (v >= SplitCount) return;
            if (this.IsEmpty) return;

            float x = rect.X;
            float y = rect.Y;
            float width = rect.Width;
            float height = rect.Height;
            if (width <= 0 || height <= 0) return;


            SkinImage skinImg = SkinImage;
            BorderOffset offset = BorderOffset;
            FillStyle style = FillStyle;
            if (skinImg == null || skinImg.Image0 == null) return;


            //g.InterpolationMode = InterpolationMode.HighQualityBilinear;
            //g.SmoothingMode = SmoothingMode.AntiAlias;
            Image img = skinImg.GetSplitYImage(v);
            GUIHelper.DrawBorderImageAndFill(g, img, x, y, width, height, offset.Top, offset.Bottom, offset.Left, offset.Right, style);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: RectangleF</param>
        public virtual void DrawImage0(Graphics g, RectangleF rect)
        {
            DrawImage(g, 0, rect);
        }


        



        /// <summary>
        /// 删除所有缓存的图片
        /// </summary>
        public virtual void ClearCache()
        {
            if (m_HashImage == null) return;

            try
            {
                foreach (KeyValuePair<int, Hash<Hash<int, Image>>> pairVHashSize in m_HashImage)
                {
                    try
                    {
                        Hash<Hash<int, Image>> hashSize = pairVHashSize.Value;
                        foreach (KeyValuePair<string, Hash<int, Image>> pairKHashCtrl in hashSize)
                        {
                            try
                            {
                                Hash<int, Image> hashCtrl = pairKHashCtrl.Value;
                                if (hashCtrl != null && hashCtrl.Count>=1)
                                {
                                    Image img = hashCtrl.GetValueByIndex(0);
                                    hashCtrl.Clear();
                                    try { if (img != null) img.Dispose(); } catch (Exception ex) { Tools.LogWarn(ex); }
                                }
                            }
                            catch (Exception ex) { Tools.LogWarn(ex); }
                        }
                        hashSize.Clear();
                    }
                    catch (Exception ex) { Tools.LogWarn(ex); }
                }
                m_HashImage.Clear();
            }
            catch (Exception ex) { Tools.LogWarn(ex); }
        }
        /// <summary>
        /// 删除 指定控件 缓存的图片
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        public virtual void ClearCache(int hashCode)
        {
            if (m_HashImage == null) return;

            try
            {
                List<int> listDV = new List<int>();
                foreach (KeyValuePair<int, Hash<Hash<int, Image>>> pairVHashSize in m_HashImage)
                {
                    try
                    {
                        Hash<Hash<int, Image>> hashSize = pairVHashSize.Value;
                        List<string> listDSize = new List<string>();
                        foreach (KeyValuePair<string, Hash<int, Image>> pairKHashCtrl in hashSize)
                        {
                            try
                            {
                                Hash<int, Image> hashCtrl = pairKHashCtrl.Value;
                                if (hashCtrl != null)
                                {
                                    Image img = hashCtrl[hashCode];
                                    hashCtrl.Remove(hashCode);
                                    if (hashCtrl.Count <= 0)
                                    {
                                        try { if (img != null) img.Dispose(); } catch (Exception ex) { Tools.LogWarn(ex); }
                                        listDSize.Add(pairKHashCtrl.Key);
                                    }
                                }
                            }
                            catch (Exception ex) { Tools.LogWarn(ex); }
                        }
                        if (listDSize.Count >= 1) foreach (string tempSize in listDSize) try { hashSize.Remove(tempSize); } catch (Exception ex) { Tools.LogWarn(ex); }
                        if (hashSize.Count <= 0) listDV.Add(pairVHashSize.Key);
                    }
                    catch (Exception ex) { Tools.LogWarn(ex); }
                }
                if (listDV.Count >= 1) foreach (int tempV in listDV) try { m_HashImage.Remove(tempV); } catch (Exception ex) { Tools.LogWarn(ex); } 
            }
            catch (Exception ex) { Tools.LogWarn(ex); }
        }
        /// <summary>
        /// 删除 指定控件 缓存的图片
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="v">Type: int</param>
        public virtual void ClearCache(int hashCode, int v)
        {
            if (m_HashImage == null) return;

            try
            {
                Hash<Hash<int, Image>> hashSize = m_HashImage[v];
                if (hashSize != null)
                {
                    List<string> listDSize = new List<string>();
                    foreach (KeyValuePair<string, Hash<int, Image>> pairKHashCtrl in hashSize)
                    {
                        try
                        {
                            Hash<int, Image> hashCtrl = pairKHashCtrl.Value;
                            if (hashCtrl != null)
                            {
                                Image img = hashCtrl[hashCode];
                                hashCtrl.Remove(hashCode);
                                if (hashCtrl.Count <= 0)
                                {
                                    try { if (img != null) img.Dispose(); } catch (Exception ex) { Tools.LogWarn(ex); }
                                    listDSize.Add(pairKHashCtrl.Key);
                                }
                            }
                        }
                        catch (Exception ex) { Tools.LogWarn(ex); }
                    }
                    if (listDSize.Count >= 1) foreach (string tempSize in listDSize) { try { hashSize.Remove(tempSize); } catch (Exception ex) { Tools.LogWarn(ex); } }
                    m_HashImage.Remove(v);
                }

            }
            catch (Exception ex) { Tools.LogWarn(ex); }
        }

        /// <summary>
        /// 创建作为当前实例副本的新对象。
        /// </summary>
        /// <returns>作为此实例副本的新对象。</returns>
        public virtual object Clone()
        {
            Type type = this.GetType();
            SkinBorderImage clone = (SkinBorderImage)Activator.CreateInstance(type);

            clone.m_FillStyle = this.m_FillStyle;
            clone.m_BorderOffset = this.m_BorderOffset;
            clone.m_SkinImage = this.m_SkinImage == null ? null : (SkinImage)this.m_SkinImage.Clone();
            
            return clone;
        }
        /// <summary>
        /// 返回表示当前 System.Object 的 System.String。
        /// </summary>
        /// <returns>System.String，表示当前的 System.Object。</returns>
        public override string ToString()
        {
            return this.GetType().Name;
        }
        /// <summary>
        /// 执行与释放或重置非托管资源相关的应用程序定义的任务。
        /// </summary>
        public virtual void Dispose()
        {
            try { if (m_SkinImage != null) { m_SkinImage.Dispose(); } } catch (Exception ex) { Tools.LogWarn(ex); m_SkinImage = null; }

            ClearCache();
            //if (m_SplitArray != null)
            //{
            //    for (int i = 0, c = m_SplitArray.Length; i < c; i++)
            //    {
            //        Image img = m_SplitArray[i];
            //        try { if (img != null) { img.Dispose(); } }
            //        catch { m_SplitArray[i] = null; }
            //    }
            //    m_SplitArray = null;
            //}
        }

    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V2 : SkinBorderImage
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V2() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V2</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V2(SkinImage_V2 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 2; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V2();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage1(int hashCode, int width, int height) { return GetImage(1, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage1(Graphics g, Rectangle rect)
        {
            DrawImage(g, 1, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V3 : SkinBorderImage_V2
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V3() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V3</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V3(SkinImage_V3 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 3; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V3();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage2(int hashCode, int width, int height) { return GetImage(2, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage2(Graphics g, Rectangle rect)
        {
            DrawImage(g, 2, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V4 : SkinBorderImage_V3
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V4() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V4</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V4(SkinImage_V4 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 4; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V4();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage3(int hashCode, int width, int height) { return GetImage(3, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage3(Graphics g, Rectangle rect)
        {
            DrawImage(g, 3, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V5 : SkinBorderImage_V4
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V5() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V5</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V5(SkinImage_V5 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 5; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V5();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage4(int hashCode, int width, int height) { return GetImage(4, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage4(Graphics g, Rectangle rect)
        {
            DrawImage(g, 4, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V6 : SkinBorderImage_V5
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V6() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V6</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V6(SkinImage_V6 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 6; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V6();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage5(int hashCode, int width, int height) { return GetImage(5, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage5(Graphics g, Rectangle rect)
        {
            DrawImage(g, 5, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V8 : SkinBorderImage_V6
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V8() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V8</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V8(SkinImage_V8 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 8; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V8();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage6(int hashCode, int width, int height) { return GetImage(6, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage7(int hashCode, int width, int height) { return GetImage(7, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage6(Graphics g, Rectangle rect)
        {
            DrawImage(g, 6, rect);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage7(Graphics g, Rectangle rect)
        {
            DrawImage(g, 7, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V9 : SkinBorderImage_V8
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V9() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V9</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V9(SkinImage_V9 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 9; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V9();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage8(int hashCode, int width, int height) { return GetImage(8, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage8(Graphics g, Rectangle rect)
        {
            DrawImage(g, 8, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V10 : SkinBorderImage_V9
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V10() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V10</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V10(SkinImage_V10 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 10; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V10();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage9(int hashCode, int width, int height) { return GetImage(9, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage9(Graphics g, Rectangle rect)
        {
            DrawImage(g, 9, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V12 : SkinBorderImage_V10
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V12() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V12</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V12(SkinImage_V12 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 12; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V12();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage10(int hashCode, int width, int height) { return GetImage(10, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage11(int hashCode, int width, int height) { return GetImage(11, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage10(Graphics g, Rectangle rect)
        {
            DrawImage(g, 10, rect);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage11(Graphics g, Rectangle rect)
        {
            DrawImage(g, 11, rect);
        }
    }
    /// <summary>
    /// 
    /// </summary>
    public class SkinBorderImage_V16 : SkinBorderImage_V12
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public SkinBorderImage_V16() { }
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="skinImg">Type: SkinImage_V16</param>
        /// <param name="top">Type: </param>
        /// <param name="bottom">Type: </param>
        /// <param name="left">Type: </param>
        /// <param name="right">Type: </param>
        /// <param name="fillStyle">Type: </param>
        public SkinBorderImage_V16(SkinImage_V16 skinImg, int top, int bottom, int left, int right, FillStyle fillStyle) : base(skinImg, top, bottom, left, right, fillStyle) { }
        /// <summary>
        /// 
        /// </summary>
        public override int SplitCount
        {
            get { return 16; }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public override SkinImage InitSkinImage()
        {
            SkinImage = new SkinImage_V16();
            return SkinImage;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage12(int hashCode, int width, int height) { return GetImage(12, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage13(int hashCode, int width, int height) { return GetImage(13, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage14(int hashCode, int width, int height) { return GetImage(14, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="hashCode">Type: int</param>
        /// <param name="width">Type: int</param>
        /// <param name="height">Type: int</param>
        /// <returns></returns>
        public virtual Image GetImage15(int hashCode, int width, int height) { return GetImage(15, hashCode, width, height); }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage12(Graphics g, Rectangle rect)
        {
            DrawImage(g, 12, rect);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage13(Graphics g, Rectangle rect)
        {
            DrawImage(g, 13, rect);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage14(Graphics g, Rectangle rect)
        {
            DrawImage(g, 14, rect);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="g">Type: Graphics</param>
        /// <param name="rect">Type: Rectangle</param>
        public virtual void DrawImage15(Graphics g, Rectangle rect)
        {
            DrawImage(g, 15, rect);
        }
    }



}
